from enthought.tvtk.api import tvtk
from enthought.pyface.tvtk import actors
from enthought.tvtk.tools import ivtk
import myActors

def imageActor(fn='/home/bryan/out1.png'):
    ir = tvtk.PNGReader(file_name=fn)
    ia = tvtk.ImageActor(input=ir.output)
    ia.add_trait('test','This is a test')
    return ia

def earthActor(size=250):
    tmp = actors.earth_actor(radius=size, opacity=1.0)
    return tmp

def coneActor(size=250):
    tmp = actors.cone_actor(height=2*size,radius=size)
    return tmp

def cubeActor(size=250):
    tmp = actors.cube_actor()
    return tmp

def cylinderActor(size=250):
    tmp = actors.cylinder_actor()
    tmp.scale=(250,250,250)
    return tmp

def arrowActor(size=250):
    tmp = actors.arrow_actor()
    return tmp

def sphereActor(size=250):
    tmp = actors.sphere_actor(radius=size)
    return tmp

def createViewer(size=(512,512)):
    return ivtk.IVTK(size)

def addActors(actors, viewer):
    viewer.open()
    viewer.scene.add_actors(actors)
    
def removeActors(actors, viewer):
    viewer.scene.remove_actors(actors)

def getAllActors():
    ACTORS = []
    actorFuncs = [getattr(myActors, x) for x in dir(myActors)
        if x.endswith('Actor')]
    for i in range(len(actorFuncs)):
        # Create the actor.
        func = actorFuncs[i]
        ACTORS.append(func())
    return ACTORS
